import request from '@/api/request' // 假设 request.ts 的路径为 @/plugin/request

export const createCategory = (data: any) => {
  return request.post('/categories', data)
}

export const getCategories = () => {
  return request.get('/categories')
}

export const updateCategory = (id: number, data: any) => {
  return request.put(`/categories/${id}`, data)
}

export const deleteCategory = (id: number) => {
  return request.delete(`/categories/${id}`)
}

export const getUnits = () => {
  return request.get('/units')
}

// 添加单位
export const createUnit = (data: any) => {
  return request.post('/units', data)
}

// 更新单位
export const updateUnit = (id: number, data: any) => {
  return request.put(`/units/${id}`, data)
}

// 删除单位
export const deleteUnit = (id: number) => {
  return request.delete(`/units/${id}`)
}

// 获取产品列表
export const getProducts = () => {
  return request.get('/products')
}

// 新建产品
export const createProduct = (data: any) => {
  return request.post('/products', data)
}

// 更新产品
export const updateProduct = (id: number, data: any) => {
  return request.put(`/products/${id}`, data)
}

// 删除产品
export const deleteProduct = (id: number) => {
  return request.delete(`/products/${id}`)
}